function makeIterator(array) {
  let nextIndex = 0
  return {
    next() {
      return nextIndex < array.length
        ? {
            value: array[nextIndex++],
            done: false
          }
        : {
            done: true
          }
    }
  }
}

const it = makeIterator(['yo', 'ya'])

console.log(it.next().value) // 'yo'
console.log(it.next().value) // 'ya'
console.log(it.next().done) // true
